<?php

namespace Agp\CoreBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Doctrine\Common\Collections\ArrayCollection;
use APY\DataGridBundle\Grid\Mapping as GRID;

/**
 * Agp\CoreBundle\Entity\Chip
 *
 * @ORM\Table(name="chip")
 * @ORM\Entity(repositoryClass="Agp\CoreBundle\Repository\ChipRepository")
 * 
 * @GRID\Source(columns="codChip, iccid, tipo, operadora, numero")
 */
class Chip
{
    /**
     * @var integer $codChip
     *
     * @ORM\Column(name="cod_chip", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     * 
     * @GRID\Column(title="Código", type="text", size="5", primary=true, visible=false)
     */
    protected $codChip;

    /**
     * @var string $iccid
     *
     * @ORM\Column(name="iccid", type="string", length=80)
     * @Assert\Length(
     *      max = "80"
     * )
     * 
     * @Assert\NotBlank()
     * 
     * @GRID\Column(title="Iccid", type="text")
     */
    protected $iccid;
    
    const OP_CLARO = 'Claro';
    const OP_VIVO  = 'Vivo';
    const OP_TIM   = 'Tim';
    const OP_OI    = 'Oi';
    const OP_CTBC    = 'CTBC';
    const OP_OUTRA    = 'Outra';
    /**
     * @var string $operadora
     *
     * @ORM\Column(name="operadora", type="string", length=45, nullable=true)
     * @Assert\NotBlank(groups={"lyra"})
     * 
     * @GRID\Column(title="Operadora", type="text")
     */
    protected $operadora;
    
    const TP_LYRA = 'Lyra';
    const TP_MULTI = 'Multi Operadora';
    /**
     * @var string $tipo
     *
     * @ORM\Column(name="tipo", type="string", length=45)
     * @Assert\NotBlank
     * 
     * @GRID\Column(title="Tipo", type="text")
     */
    protected $tipo;


    /**
     * @var string $numero
     *
     * @ORM\Column(name="numero", type="bigint", nullable=true)
     * 
     * @GRID\Column(title="Número", type="text")
     */
    protected $numero;

    public function getCodChip() {
        return $this->codChip;
    }

    public function setCodChip($codChip) {
        $this->codChip = $codChip;
    }

    public function getIccid() {
        return $this->iccid;
    }

    public function setIccid($iccid) {
        $this->iccid = $iccid;
    }

    public function getOperadora() {
        return $this->operadora;
    }

    public function setOperadora($operadora) {
        $this->operadora = $operadora;
    }

    public function getTipo() {
        return $this->tipo;
    }
    
    public function getNumericoTipo(){
        if ($this->tipo == self::TP_LYRA){
            return 0;
        }elseif($this->tipo == self::TP_COMERCIAL){
            return 1;
        }
    }

    public function setTipo($tipo) {
        $this->tipo = $tipo;
    }

    public function getNumero() {
        return $this->numero;
    }

    public function setNumero($numero) {
        $this->numero = $numero;
    }

    public static function getOperadoraList(){
        return array(self::OP_CLARO => self::OP_CLARO,
                     self::OP_OI => self::OP_OI,
                     self::OP_TIM => self::OP_TIM,
                     self::OP_VIVO => self::OP_VIVO,
                     self::OP_CTBC => self::OP_CTBC,
                     self::OP_OUTRA => self::OP_OUTRA);
    }
    
    public static function gettipoList(){
        return array(self::TP_LYRA => self::TP_LYRA,
                     self::TP_MULTI => self::TP_MULTI);
    }
 
}
